import { getCurentDate, transformNumber } from "@/hooks/useCommon";

const { curDay, curMonth, curYear } = getCurentDate();
export const getCurentPaperMonth = () => {
  return curDay <= 7 ? curMonth - 1 : curMonth;
};
function generateMonths() {
  const count = getCurentPaperMonth();
  let arr = new Array(count).fill({ align: "left" });
  return arr.map((item, index) => ({
    ...item,
    slot: true,
    prop: `m${index + 1}`,
    label: `${String(index + 1)}月支付总额（万元）`,
    width: 120,
  }));
}
function generateYears() {
  const count = curYear - 2022 + 1
  let arr = Array(count).fill().map((_, idx) => idx).reverse()
  return arr.map((item, index) => {
    let label = ''
    if(index === 0) {
      label = '初始至2022年执行额'
    }else if(index === arr.length - 1) {
      label = '至今投额执行总额'
    }else {
      label = `${curYear - item}年执行额`
    }
    return {
      prop: `y${curYear - item}`,
      label,
      width: 120,
    }
  })
}

export const fixedInvestColumns = [
  {
    label: "实施主体",
    prop: "companyName",
    width: 100,
    overHidden: false,
  },
  {
    label: "项目编码",
    prop: "fixedProjectId",
    width: 120,
    overHidden: false,
  },
  {
    label: "项目名称",
    prop: "projectName",
    width: 150,
    overHidden: false,
    fixed: "left",
  },
  ...generateMonths(),
  {
    label: `本年拟投额（调整前）`,
    prop: "plannedAmountOri",
    width: 100,
    formatter: (t, r) => transformNumber(r.plannedAmountOri || 0),
  },
  {
    label: `本年拟投额（调整后）`,
    prop: "plannedAmountAdj",
    width: 100,
    formatter: (t, r) => transformNumber(r.plannedAmountAdj),
  },
  {
    label: `本年完成率`,
    prop: "completePercent",
    width: 100,
  },
  {
    label: `本年目标缺口(万元)`,
    prop: "gap",
    width: 100,
    formatter: (t, r) => transformNumber(r.gap),
  },
  {
    label: `本年执行额(万元)`,
    prop: "totalCompleteAmount",

    width: 100,
    formatter: (t, r) => transformNumber(r.totalCompleteAmount),
  },
  ...generateYears(),
  {
    label: "建设规模(㎡)",
    prop: "constructionScale",

    width: 100,
  },
  {
    label: "建设周期",
    prop: "constructionDuration",
    width: 150,
  },
  {
    label: "项目性质",
    prop: "projectNature",
    width: 100,
  },
  {
    label: "总投额(万元)",
    prop: "totalAmount",
    width: 100,
    formatter: (t, r) => transformNumber(r.totalAmount || 0),
  },

  {
    label: "是否取得发票",
    prop: "haveInvoice",
    width: 100,
    slot: true,
  },
  {
    label: "发改固投入库",
    prop: "inWarehouse",
    width: 100,
    slot: true,
  },
  {
    label: "项目状态",
    prop: "projectStatus",
    width: 100,
    slot: true,
  },
  {
    label: "项目进展描述",
    prop: "processDescription",
    width: 300,
  },
  {
    label: "是否开工",
    prop: "isDoing",
    width: 100,
    slot: true,
  },
  {
    label: "具体开工时间",
    prop: "startTime",
    width: 150,
  },
  
  {
    label: "项目备注",
    prop: "projectContent",
    overHidden: false,
    width: 300,
    slot: true,
  },
  {
    label: "需协调备注",
    prop: "coordinateRemark",
    overHidden: false,
    width: 300,
    slot: true,
  },
];

export const equityInvestColumns = [
  {
    label: "项目编码",
    prop: "fixedProjectId",
    width: 100,
    overHidden: false,
  },
  {
    label: "项目名称",
    prop: "projectName",
    width: 150,
    overHidden: false,
    fixed: "left",
  },
  {
    label: "实施主体",
    prop: "companyName",
    width: 100,
    overHidden: false,
  },

  {
    label: "公司性质",
    prop: "companyNature",
    width: 100,
  },
  {
    label: "投资业务领域",
    prop: "investBusinessDomain",
    width: 100,
  },
  {
    label: "总投额(万元)",
    prop: "totalAmount",
    width: 100,
    formatter: (t, r) => (r.totalAmount ? transformNumber(r.totalAmount) : "-"),
  },
  {
    label: " 投资预期收益(年均利润)",
    prop: "expectedReturn",
    width: 100,
    formatter: (t, r) => transformNumber(r.expectedReturn),
  },
  {
    label: "实施年限",
    prop: "duration",
    width: 100,
  },
  ...generateMonths(),
  {
    label: `本年拟投额（调整前）`,
    prop: "plannedAmountOri",
    width: 100,
    formatter: (t, r) => transformNumber(r.plannedAmountOri),
  },

  {
    label: `本年拟投额（调整后）`,
    prop: "plannedAmountAdj",
    width: 100,
    formatter: (t, r) => transformNumber(r.plannedAmountAdj),
  },
  {
    label: `本年执行额(万元)`,
    prop: "totalCompleteAmount",

    width: 100,
    formatter: (t, r) => transformNumber(r.totalCompleteAmount),
  },
  {
    label: `本年完成率`,
    prop: "completePercent",

    width: 100,
  },
  {
    label: `本年目标缺口(万元)`,
    prop: "gap",
    width: 100,
    formatter: (t, r) => transformNumber(r.gap),
  },
  ...generateYears(),
  {
    label: "成立时间",
    prop: "establishDate",
    overHidden: false,
    width: 100,
  },
  {
    label: `项目状态`,
    prop: "projectStatus",
    width: 100,
    slot: true,
  },
  {
    label: `项目进度描述`,
    prop: "processDescription",
    width: 300,
  },
  {
    label: `是否开工`,
    prop: "isDoing",
    width: 100,
    slot: true,
  },
  {
    label: `具体开工时间`,
    prop: "startTime",
    width: 150,
  },
  {
    label: "项目备注",
    prop: "projectContent",
    overHidden: false,
    width: 300,
    slot: true,
  },
  {
    label: "需协调备注",
    prop: "coordinateRemark",
    overHidden: false,
    width: 300,
    slot: true,
  },
];

export const investSummaryColumns = [
  {
    label: "项目",
    prop: "name",
  },
  {
    label: `本年初计划金额(万元)`,
    prop: "plannedAmountOri",

    formatter: (t, r) => transformNumber(r.plannedAmountOri),
  },
  {
    label: "调整后计划金额(万元)",
    prop: "plannedAmountAdj",

    formatter: (t, r) => transformNumber(r.plannedAmountAdj),
  },
  {
    label: "调整额(万元)",
    prop: "plannedAmountChangeValue",
    formatter: (t, r) => transformNumber(r.plannedAmountChangeValue),
  },
  {
    label: "调整率",
    prop: "plannedAmountChangeRate",
  },
  {
    label: `本年实际完成金额(万元)`,
    prop: "totalExpensiveAmount",

    formatter: (t, r) => transformNumber(r.totalExpensiveAmount),
  },
  {
    label: `本年完成比例`,
    prop: "expensiveRate",
  },
  {
    label: "备注",
    prop: "memo",
  },
];
